package book;

import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: GodK
 * Date: 2024-03-13
 * Time: 16:53
 */
public class Book {
    public String name;
    public String author;
    public int price;
    public String type;
    public boolean isLend;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public boolean isLend() {
        return isLend;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book book = (Book) o;
        return price == book.price && isLend == book.isLend && Objects.equals(name, book.name) && Objects.equals(author, book.author) && Objects.equals(type, book.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, author, price, type, isLend);
    }

    public void setLend(boolean lend) {
        isLend = lend;
    }

    public Book(String name, String author, int price, String type) {
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
    }

    @Override
    public String toString() {
        return "Book{" +
                "name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", type='" + type + '\'' +
                (isLend == true ? " 已借出":" 未借出") +
                '}';
    }
}
